***************************************************************************************
**************************************************************************************** Replication files for 
*	Long-run effects of earlier voting eligibility on turnout and political involvement
*	by Jessen, Kuehnle and Wagner
******************************************************************************************************************************************************************************

**********************************************
* 1. Prepare folders
**********************************************

* Set folder path
cd	"INSTER FOLDER PATH"

* set globals for location of data
global BHPS		"C:\Users\Jonas Jessen\Dropbox\Data\UKDA-6931-stata\UKDA-6931-stata\stata11_se"
global US 		"C:\Users\Jonas Jessen\Dropbox\Data\UKDA-6931-stata\UKDA-6931-stata\stata11_se"		
global BHPS		"INSERT PATH FOR BHPS DATA"		// requires special access
global US 		"INSERT PATH FOR US DATA"		// requires special access

* Stata version
version 18

* Start time
global start_time=c(current_time)

* Temporary files saved in "Data_temp"

* Create folders containing the output (empty them at beginning)
cap shell rmdir "Figures" 	/s /q
cap shell rmdir "Tables" 	/s /q
cap shell rmdir "Data_temp" /s /q
cap mkdir 		"Figures"
cap mkdir 		"Tables"
cap mkdir 		"Data_temp"

********************************************************************************
* 2. Load ado files
********************************************************************************

cap ssc install rdrobust
cap ssc install rdplot
cap ssc install estout
cap ssc install regsave
* ado file for McCrary density test is found in folder "ado"

********************************************************************************
* 3. Data editing
********************************************************************************

* Extract relevant variables and create one data set
do "1_1_first_edit.do"

* Create outcome variables and other variables used in analysis
do "1_2_outc_edit.do"



********************************************************************************
* 4. Figures
********************************************************************************

* Figure 1: Relative age at election t0 and turnout at subsequent elections
do "figure_1.do"

* Figure 2: Effect of earlier eligibility on political attitudes 
	// in t0—split by pre-eligibility engagement
do "figure_2.do"

* Figure 3: RD specifications - effect of earlier eligibility on voting in subsequent elections
do "figure_3.do"

* Figure 4: RD specifications - effect of earlier eligibility on political attitudes
do "figure_4.do"	
	
********************************************************************************
* 4. Tables
********************************************************************************

* Table 1: Relative age at election t0 and turnout
do "table_1.do"

* Table 2: Relationship between relative age at election t0 and political involvement
do "table_2.do"



********************************************
* End time of paper analyses
global paper_end=c(current_time)

********************************************************************************
* 7. Appendix Figures
********************************************************************************

* Figure A.1: Manipulation test of running variable
do "z_figure_a1.do"

* Figure A.2: Comparison of official turnout data and survey turnout data
do "z_figure_a2.do"

* Figure A.3: Robustness of voting coefficients to European and subnational elections
do "z_figure_a3.do"

* Figure A.4: Month of birth and age at first observed vote
do "z_figure_a4.do"

* Figure A.5: Relationship between relative age at election t0 and turnout at subsequent elections
do "z_figure_a5.do"

* Figure A.6-A.11: Reduced form graphs for political involvement
do "z_figure_a6_a11.do"

* Figure A.12: Effect of earlier eligibility on voting and political involvement—choice of kernels
do "z_figure_a12.do"

* Figure A.13: Social context by age
do "z_figure_a13.do"


********************************************************************************
* 8. Appendix Tables
********************************************************************************

* Table A.2: Balancing of covariates
do "z_table_a2.do"

* Table A.3: Relative age at European election t0 and turnout
do "z_table_a3.do"

* Table A.4: Relationship between relative age at election t0 and turnout by election
do "z_table_a4.do"

* Table A.5: Relative age at election t0 and turnout—by overall turnout
do "z_table_a5.do"

* Table A.6: Relationship between relative age at election t0 and party preferences
do "z_table_a6.do"



********************************************
* End time of all analyses
global appendix_end=c(current_time)


* Running times of analyses
dis "Start time: $start_time"
dis "End time main paper: $paper_end"
dis "End time appendix: $appendix_end"
